﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using X.Web;
using System.Web.UI.HtmlControls;

namespace X.WebSite.News
{
    public partial class Detail : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int newsId = 0;

                if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
                    newsId = Convert.ToInt32(Request.QueryString["Id"]);

                X.Entity.NewsInfo newsInfo = Bll.News.GetNewsInfo(newsId);

                this.Title = X.Common.StringUtils.HtmlDecode(newsInfo.Title) + this.Title;

                lblTitle.Text = newsInfo.Title;
                lblPostTime.Text = newsInfo.PostTime.ToString("yyyy-MM-dd");
                lblContent.Text = newsInfo.Content;
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //Keywords
            HtmlMeta keywords = new HtmlMeta();
            keywords.Name = "keywords";
            keywords.Content = SiteInfoConfig.SiteKeyword;
            Header.Controls.Add(keywords);

            //Description
            HtmlMeta description = new HtmlMeta();
            description.Name = "description";
            description.Content = SiteInfoConfig.SiteDescription;
            Header.Controls.Add(description);
        }
    }
}